<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	DateFormat format = new SimpleDateFormat("yyyyMMdd");
	Date date = new Date();
	String endDate = format.format(date);
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(date);
	calendar.add(Calendar.DAY_OF_MONTH, -7);
	String beginDate = format.format(calendar.getTime());

%>
<html>
	<head>
		<title>start</title>
		<script type="text/javascript" src="<%=path%>/js/ui.js"></script>
	    <script type="text/javascript" src="<%=path%>/js/MzCalendar.js" ></script>
	   <!--  <script type="text/javascript" src="<%=basePath %>js/autoComplete.js" ></script> -->
	    <link id="editCss" rel="stylesheet" type="text/css" href="<%=basePath %>/css/right.css" /> 
	    <link id="editCss" rel="stylesheet" type="text/css" href="<%=basePath %>/css/autoComplete.css" />
	    <!-- DWR -->
     	<script type='text/javascript' src='<%=basePath%>dwr/interface/keywordBussinees.js'></script>
		<script type='text/javascript' src='<%=basePath%>dwr/engine.js'></script>
		<script type='text/javascript' src='<%=basePath%>dwr/util.js'></script>
		<style type="text/css">
	    .selectBoard {
			width:250px;
			height:25px;
			top:300PX;
			background: #ffffff;
		}
		</style>
		<script>
		var oldKeyword = "";
		dwr.engine.setAsync(false);
		var $ = function(id) {
			return "string" == typeof id ? document.getElementById(id) : id;
		};

		// instead document.getElementById().value
		var $F = function(id) {
			return $(id).value;
		};

		var PreSeacher = {
			showDate : function(value) {
				//value = value.trim();
				if (value == '' ) {
					this.closePop();
				} else if(oldKeyword == value) {
					
				} else {
					oldKeyword = value;
					var keyword = "";
					keywordBussinees.getKeyword(value, function(reslut) {
						keyword = (new Function("return " + reslut))(); 
					});
					if(keyword != null || keyword.length > 0) {
						this.autoCallback(keyword);
					}
				}
			},

			autoCallback : function(list) {
				this.closePop();
				var table = $('selector');
				if(list.length > 0) {
					for ( var i = 0; i < list.length; i++) {
						var row = table.insertRow(0);
						var cle = row.insertCell(0);
						// onmouseout event
						row.onmouseout = function() {
							this.className = 'mouseOut';
							Assist.isOnmouseover = false;
						};
						// onmouseover event
						row.onmouseover = function() {
							this.className = 'mouseOver';
							Assist.isOnmouseover = true;
						};
						// onclick event
						row.onclick = function() {
							Assist.autoPush(this);
						};
						var text = list[i].text;
						cle.innerHTML = text;
					};
					$("searchBoard").className = "searchBoard";
				}
			},

			closePop : function() {
				var x = $('selector');
				var length = x.rows.length;
				for ( var i = 0; i < length; i++) {
					x.deleteRow(0);
				}
				$("searchBoard").className = "borderNull";
			}
		};

		var Assist = {
			isOnmouseover : false,
			// close the auto complete message when onclick the page of the body(input
			// lose focus)
			autoClose : function() {
				if (this.isOnmouseover == false) {
					PreSeacher.closePop();
				}
			},

			autoPush : function(obj) {
				$("keyword").value = obj.childNodes[0].firstChild.nodeValue;
				PreSeacher.closePop();
				// document.forms[0].submit();
			}

		};

	</script>
	</head>
	<body>
		<div class="search">
			<div class="tab">
				<span class="right"></span>
				<span class="font-blue14pxb">搜索</span>
			</div>
		</div>
		<form id="searchForm" name="searchForm" method="post"
			action="/zebra/customer/search/SearchAction">
			<input type="hidden" name="method" id="method" value="search" />
			<div class="search">
				<ul class="con minHeight">
					<li style="width: auto;">
						<font>搜索设定：</font>
					</li>
					<li style="width: auto;">
						<%-- 日期搜索  --%>
						<font>日期</font>
						<input type="text" class="text" id="beginDate" name="beginDate"
							value="<%=beginDate%>" readonly="readonly" />
						<img src="<%=basePath%>/images/timeIco.gif"
							onclick="WebCalendar.start(this,document.getElementById('beginDate'), 'yyyyMMdd')" />
						至
						<input type="text" class="text" id="endDate" name="endDate"
							value="<%=endDate%>" readonly="readonly" />
						<img src="<%=basePath%>/images/timeIco.gif"
							onclick="WebCalendar.start(this,document.getElementById('endDate'), 'yyyyMMdd')" />
					</li>
					<li style="width: auto;">
						<input type="checkbox" name="isSearchContent" id="isSearchContent" value="1"  checked="checked"/>
							搜索正文
					</li>
				</ul>
			</div>
			
			<div style="margin: 50px auto; text-align: center;">
				<input  type="text" name="keyword" id="keyword" style="width:250px;height:25px;top:300PX;" autocomplete="off"
				 onkeyup="PreSeacher.showDate(this.value);" onblur="Assist.autoClose();" />
				<input  class="button" type="submit" value="搜索" style="width:50px;height:25px;top:300PX;"/>
				
				<div id="searchBoard" class="borderNull">
					<table id="selector" border="0" width="100%" cellpadding="0" cellspacing="0">
					</table>
				</div>
				
			</div>
			
		</form>
	</body>
</html>
